<template>
	<view class="page">
		<view style="height: 250rpx;"></view>
		<video class="video" :poster="goodsInfo.goods_image_primary" :src="goodsInfo.goods_video" controls></video>
		<view class="good_name">商品名称：
			<text>{{goodsInfo.goods_name}}</text>
		</view>
		<view class="good_name">商品单价：
			<text>￥{{goodsInfo.goods_price}}</text>
		</view>
		<view class="btn-box">
			<view @click="toDetail">查看详情
				<image :src="`${picUrl}/w/more.png`"></image>
			</view>
			<view @click="toBuy">立即购买
				<image :src="`${picUrl}/w/more.png`"></image>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				goodsInfo: "",
				num: 1, //数量
				type: 1, //type:1为普通购买，2为拼团购买，3为砍价订单 6秒杀
				SpellGroup_sn: "",
			}
		},
		onLoad(options) {
			if (options.goodsInfo) {
				this.goodsInfo = JSON.parse(decodeURIComponent(options.goodsInfo))
				console.log('goodsInfo', this.goodsInfo)
			}
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#000000',
			})
		},
		methods: {
			//查看详情
			toDetail() {
				uni.navigateTo({
					url: `/mall/goods/info?goods_id=` + this.goodsInfo.goods_id+'&share_phyid='+this.goodsInfo.physical_id
				})
			},
			//立即购买
			toBuy() {
				if (!uni.getStorageSync("key")) {
					uni.navigateTo({
						url: "/mainA/login/login"
					})
					return
				}
				//  is_virtual商品类型
				uni.navigateTo({
					url: '/mall/order/confirm?cart_id=' + this.goodsInfo.goods_id + '|' + this
						.num + '&ifcart=0' + '&order_type=' + this.type + "&SpellGroup_sn=" + this
						.SpellGroup_sn + '&is_virtual=' + this.goodsInfo.is_virtual
				})
			}
		},
	}
</script>
<style lang="scss" scoped>
	.page {
		height: 100vh;
		background-color: black;
		position: relative;
	}

	.good_name {
		width: 90%;
		margin: 10rpx auto;
		font-size: 30rpx;
		color: #FFFFFF;

		text {
			font-size: 34rpx;
			font-weight: bold;
		}
	}

	.video {
		width: 100%;
		display: flex;
		margin-bottom: 40rpx;
		height: 423rpx;
	}

	.btn-box {
		position: absolute;
		display: flex;
		width: 80%;
		left: 10%;
		bottom: 100rpx;
		height: 80rpx;

		view {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #FF9A01;
			border-radius: 50rpx 0 0 50rpx;
			color: #ffffff;
			font-size: 30rpx;

			image {
				margin-left: 10rpx;
				width: 20rpx;
				height: 20rpx;
			}
		}
	}

	.btn-box view:last-child {
		margin-right: 0rpx;
		border-radius: 0rpx 80rpx 80rpx 0rpx;
		background: #E6442F;
	}
</style>